package com.byxy.dao;

import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;

import com.byxy.entity.User;
import com.byxy.provider.UserProvider;

public interface UserDao {

//	ע��
//	@Insert("insert into user(user_name,user_nick,user_password,user_type) values(#{userName},#{userNick},#{userPassword},#{userType})")
	@InsertProvider(type=UserProvider.class,method="insert")
	void signUp(User user);
	
	@UpdateProvider(type=UserProvider.class,method="update")
	void update(User user);

//	��ʵ�����֣�
	@ResultMap("userMap")
	@Select("Select * from user where user_name=#{userName}")
	User getByName(String userName);

	@Results(id = "userMap" , value = { @Result(column = "user_id", property = "userId", id = true),
			@Result(column = "user_name", property = "userName"), 
			@Result(column = "user_nick", property = "userNick"),
			@Result(column = "user_password", property = "userPassword"),
			@Result(column = "user_status", property = "userStatus"),
			@Result(column = "user_type", property = "userType") })
	@Select("select * from user where user_id=#{userId}")
	User getById(Integer userId);
	
	/** ��¼ */
	@ResultMap("userMap")
	@Select("select * from user where user_name=#{userName} and user_password=#{userPassword}")
	User getByNameAndPassword(@Param("userName")String userName,@Param("userPassword")String userPassword);
}
